﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="VehicleEdit.aspx.cs" Inherits="Web.VehicleEdit" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>用车申请 编辑</title>
    <base target="_self" />
    <meta content="ie=7" http-equiv="x-ua-compatible">
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
    <META HTTP-EQUIV="Expires" CONTENT="0">
    <link href="Styles/Style01.css" rel="stylesheet" type="text/css" />
    <script src="Scripts/jquery-1.7.min.js" type="text/javascript"></script>
    <link href="Styles/validate.css" rel="stylesheet" type="text/css" />
    <script src="Scripts/easy_validator.pack.js" type="text/javascript"></script>
    <script src="Content/scripts/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script>
        //iframe高度自适应
        function IFrameReSize(iframename) {
            var pTar = document.getElementById(iframename);
            if (pTar) {  //ff
                if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight) {
                    pTar.height = pTar.contentDocument.body.offsetHeight;
                } //ie
                else if (pTar.Document && pTar.Document.body.scrollHeight) {
                    pTar.height = pTar.Document.body.scrollHeight;
                }
            }
        }
        //iframe宽度自适应
        function IFrameReSizeWidth(iframename) {
            var pTar = document.getElementById(iframename);
            if (pTar) {  //ff
                if (pTar.contentDocument && pTar.contentDocument.body.offsetWidth) {
                    pTar.width = pTar.contentDocument.body.offsetWidth;
                }  //ie
                else if (pTar.Document && pTar.Document.body.scrollWidth) {
                    pTar.width = pTar.Document.body.scrollWidth;
                }
            }
        }

        //取get参数
        function getArg() {
            var url = unescape(window.location.href);
            var allArgs = url.split("?")[1];
            if (allArgs != null) {
                var args = allArgs.split("&");
                for (var i = 0; i < args.length; i++) {
                    var arg = args[i].split("=");
                    eval('this.' + arg[0] + '="' + arg[1] + '";');
                }
            }
        }
        var urlArg = new getArg();
        var formNo = urlArg.formNo;

        $(function () {
            $("[reg]").parents("td").prev().append("<font color='#ff0000'>*</font>");
            $("#btnSave").click(function () {
                return formValid();
            });
            $("#btnSubmit").click(function () {
                var trs = $("#tbDetail tbody").find("tr");
                if (trs.length == 0) { alert('请增加 旅程明细~');return false; }
                return formValid();
            });
        });
        function formValid() {
            var isSubmit = true;
            $("form").find("[reg],[url]:not([reg])").each(function () {
                if (!validate($(this), this.tagName)) {
                    isSubmit = false;
                }
            });
            if (!isSubmit) {
                alert("请确认'红字或红框'处的输入正确!");
                return false;
            }
            return true;
        }
        function scheduleEdit(id) {
            var url = 'VehiScheduleEdit.aspx?formNo=' + formNo;
            if (id != undefined) {
                url = 'VehiScheduleEdit.aspx?id=' + id;
            }
            var retVal = window.showModalDialog(url, window, 'dialogWidth=550px;dialogHeight=550px;status=no;help=no;resizable=yes;');
            if (retVal != undefined && retVal.indexOf('Succeed') >= 0) {
                window.name = "__self";
                window.open(window.location.href, "__self");
            }
        }
        function scheduleDel(id) {
            if (confirm('您确定删除该行记录吗?')) {
                $.ajax({ type: 'post', url: "/Vehicle.mvc/DelDetail", data: { id: id },
                    success: function (data, textStatus) {
                        if (data == "Succeed") {
                            window.name = "__self";
                            window.open(window.location.href, "__self");
                        }
                    }
                });
            }
        }
    </script>
</head>
<body>
<form id="Form1" runat=server><input type=hidden runat=server id=FormNo />
<table class="s1">
<tr><td>表单编号</td><td><%=reqVehicleMains.FormNo%></td><td>申请时间</td><td><%=reqVehicleMains.ReqDate.ToString("yyyy-MM-dd HH:mm:ss")%></td></tr>
<tr><td>申请人</td><td><%=empName%></td><td>申请车辆</td>
<td><select id="Vehicle" runat="server" title="不能为空" reg=".">
<option value="">请选择</option>
<option value="别克7座(粤SJH551)">别克7座(粤SJH551)</option>
<option value="奔驰7座(粤S.1380N)">奔驰7座(粤S.1380N)</option>
<option value="金杯11座(粤S45620)">金杯11座黄江专用(粤S45620)</option>
<option value="金杯商务车9座(粤S.9610G)">金杯商务车9座(粤S.9610G)</option>
<option value="丰田中巴30座(粤A.06065)">丰田中巴30座(粤A.06065)</option>
<option value="其他车辆">其他车辆</option>
</select></td></tr>
<tr><td>同行人</td><td><input id="Riders" runat="server"></td><td>乘车人数</td><td><input id="RiderCnt" runat="server" value="0" title="请输入整数值" reg="^\d+$"/></td></tr>
<tr><td>用车开始时间</td><td><input id="PreStartTime" runat="server" class="Wdate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'});" title="格式:yyyy-MM-dd HH:mm:ss" reg="."></td>
<td>用车终止时间</td><td><input id="PreEndTime" runat="server" class="Wdate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'});" title="格式:yyyy-MM-dd HH:mm:ss" reg="."></td></tr>
<tr><td>申请备注</td><td colspan=3><input id="Cause" runat="server"></td></tr>
</table>
<asp:Repeater ID="rptList" EnableViewState="false" Runat="server">
	<HeaderTemplate>
		<table id="tbDetail" class="s1 list">
			<caption>旅程明细<input type=button onclick="javascript:scheduleEdit();" value="添加旅程"/></caption>
			<thead>
				<TR>
					<th width="10%">出发地</th>
					<th width="10%">到达地</th>
					<th width="15%">预计距离</th>
					<th width="15%">预计时长</th>
					<th width="20%">备注</th>
					<th class="tdOrder">操作</th>
				</TR>
			</thead><tbody>
	</HeaderTemplate>
	<ItemTemplate>
		<tr class="<%# Container.ItemIndex%2==0?"bg":""%>">
			<td><%#Eval("FromSite")%></td>
			<td><%#Eval("ToSite")%></td>
			<td><%#Eval("PreDistance")%></td>
			<td><%#Eval("PreTimespan")%></td>
			<td><%#Eval("Cause")%></td>
			<td>
                <a href="#" onclick="scheduleEdit(<%# DataBinder.Eval(Container.DataItem,"Id") %>);return false;">[编辑]</a>
                <a href="#" onclick="scheduleDel(<%# DataBinder.Eval(Container.DataItem,"Id") %>);return false;">[删除]</a>
			</td>
		</tr>
	</ItemTemplate>
	<FooterTemplate>
		</tbody> </table>
	</FooterTemplate>
</asp:Repeater>
<div style="text-align:right;margin-right:24px;margin-top:6px;">
    <asp:button runat="server" text="保存" class="btn" id="btnSave" onclick="btnSave_Click"/>
    <asp:button runat="server" text="提交" class="btn" id="btnSubmit" onclick="btnSubmit_Click"/>
    <input type=button value="关闭" class="btn" onclick="window.close();" />
</div>
</form>
</body>
</html>